<?php
add_action('admin_init', 'cp_options_init' );
add_action('admin_menu', 'cp_options_add_page');
//add_action('admin_head', 'admin_head_add');

// Draw the menu page itself
function cp_options_do_page() {
	?>
	<div class="wrap">
		<div class="ui-icon ui-icon-wrench"></div>
		<h2>Carbon Paper Options</h2>
		<form method="post" action="options.php">
			<?php settings_fields('cp_options'); ?>
			<?php $options = get_option('carbonpaper'); ?>
			<table class="form-table">
				<tr valign="top"><th scope="row">A Checkbox</th>
					<td><input name="carbonpaper[option1]" type="checkbox" value="1" <?php checked('1', $options['option1']); ?> /></td>
				</tr>
				<tr valign="top"><th scope="row">Some text</th>
					<td><input type="text" name="carbonpaper[sometext]" value="<?php echo $options['sometext']; ?>" /></td>
				</tr>
			</table>
			<p class="submit">
			<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
			</p>
		</form>
	</div>
	<?php	
}

// Sanitize and validate input. Accepts an array, return a sanitized array.
function cp_options_validate($input) {
	// Our first value is either 0 or 1
	$input['option1'] = ( $input['option1'] == 1 ? 1 : 0 );
	
	// Say our second option must be safe text with no HTML tags
	$input['sometext'] =  wp_filter_nohtml_kses($input['sometext']);
	
	return $input;
}
?>